package com.ruoyi.hr.controller.hr.salaryquery.monthsalaryhistory;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.hr.service.salaryquery.MonthSalaryHistoryService;
import com.ruoyi.hr.util.BaseResult;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * @author zeo
 * @explain 月薪资历史导入
 * @date 2020/3/14
 */
@Controller
@RequestMapping("/salaryQuery/MonthSalaryHistory")
public class MonthSalaryHistoryController extends BaseController {

    @Autowired
    MonthSalaryHistoryService monthSalaryHistoryService;

    @Autowired
    ISysUserService iSysUserService;

    private String prefix = "hr/salaryquery/monthsalaryhistory";

    /**
     * 跳转分页页面
     */
    @GetMapping()
    public String monthSalaryHistoryImp() {
        return prefix + "/monthSalaryHistoryImp";
    }

    @RequestMapping("/getPayGroup")
    @ResponseBody
    public List<Map<String, Object>> getPayGroup() {
        SysUser user = ShiroUtils.getSysUser();
        Map<String, Object> maps = iSysUserService.selectSkySecUser(user.getLoginName());
        return monthSalaryHistoryService.getPayGroup(maps.get("id").toString());
    }

    @RequestMapping("/findPro")
    @ResponseBody
    public List<String> findPro(String jsid) {
        return monthSalaryHistoryService.findPro(jsid);
    }

    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam Map map) {
        return getDataTable(monthSalaryHistoryService.findData(map));
    }

    /**
     * 导出
     */
    @RequestMapping("/exportData")
    @ResponseBody
    public AjaxResult exportSalaryData(String jsid) throws Exception {
        return monthSalaryHistoryService.exportData(jsid);
    }

    /**
     * 导入
     */
    @RequestMapping("/importData")
    @ResponseBody
    public AjaxResult importData(MultipartFile file, String jsid) throws Exception {
        return monthSalaryHistoryService.importData(file, jsid);
    }

    @RequestMapping("/synchronization")
    @ResponseBody
    public BaseResult synchronization(String jsid){
        return monthSalaryHistoryService.synchronization(jsid);
    }


    @GetMapping("/monthSalaryHistory")
    public String monthSalaryHistory(){
        return prefix + "/monthSalaryHistory";
    }

    @RequestMapping("/historyList")
    @ResponseBody
    public TableDataInfo historyList(@RequestParam Map map) {
        return getDataTable(monthSalaryHistoryService.historyList(map));
    }

}
